package koscom.corebase.nam;
import java.awt.Color;
import java.awt.Component;
import java.awt.EventQueue;
import java.awt.Font;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.nio.ByteBuffer;
import java.text.NumberFormat;
import java.text.ParseException;
import java.util.Enumeration;

import javax.swing.DefaultComboBoxModel;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFormattedTextField;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.ListSelectionModel;
import javax.swing.UIDefaults;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
import javax.swing.table.TableColumn;
import javax.swing.text.MaskFormatter;
import javax.swing.text.NumberFormatter;


@SuppressWarnings("serial")
public class A2001 extends JFrame {

	private JPanel contentPane;
	private JFormattedTextField txtAccNum;
	private JPasswordField txtPassword;
	private JTextField txtResult;
	private DefaultTableModel mdlAccLimit;
	private DefaultTableModel mdlAccStat;
	private DefaultTableModel mdlAccHistory;
	private JScrollPane scpAccLimit;
	private JScrollPane scpAccStat;
	private JTable tblAccLimit;
	private JTable tblAccStat;
	private JLabel lblNewLabel_1;
	private JLabel lblNewLabel_3;
	private JScrollPane scpAccHistory;
	private JLabel label;
	private JTable tblAccHistory;
	private JLabel lblNewLabel_2;
	private JLabel lblNewLabel_4;
	private JComboBox cmbProcessType;
	private JLabel lblNewLabel_6;
	private JButton btnOK;
	private JComboBox cmbAccidentType;
	private JSeparator separator;
	private JTextField txtAccName;
	NumberFormatter numberFormatter;
	SClient client;
	int tableSelectedRow = -1;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		//기본 폰트 설정
		try {
			UIDefaults swingComponentDefaultTable = UIManager.getDefaults();
			Enumeration<Object> allDefaultKey = swingComponentDefaultTable.keys();
			while(allDefaultKey.hasMoreElements()) {
				String defaultKey = allDefaultKey.nextElement().toString();
				if(defaultKey.indexOf("font") != -1) {
					Font newDefaultFont = new Font("맑은 고딕", Font.PLAIN, 12);
					//System.out.println(defaultKey);
					UIManager.put(defaultKey, newDefaultFont);
				}
			}
		UIManager.getDefaults().put("Button.margin", new Insets(0,0,0,0));
		} catch (Exception e) {
			e.printStackTrace();
		}
				
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					A2001 frame = new A2001();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public A2001() {
		
		MaskFormatter mf1 = null;
		try {
			mf1 = new MaskFormatter("###-##-######");
		} catch (ParseException e1) {
			e1.printStackTrace();
		}
		
		numberFormatter = new NumberFormatter( 
	            NumberFormat.getIntegerInstance());
		numberFormatter.setAllowsInvalid(false);  
	    numberFormatter.setCommitsOnValidEdit(true);
	    
	    client = new SClient(null, 0, false);
	    //onRcvData
	    client.setListener(new SClient.OnListener() {
			@Override
			public void onRcvData(ByteBuffer rcvBuff) {
				try {
					byte[] trid = new byte[6];
					rcvBuff.get(trid, 0, trid.length);
					String trString = new String(trid, "UTF-8");
					
					if(trString.equals("2222OO"))
					{
						System.out.println("2222OO");
						byte[] bytes = new byte[rcvBuff.remaining()];
						rcvBuff.get(bytes);
						String rString = new String(bytes, "UTF-8");
						txtAccName.setText(rString.substring(0,20).trim());
						txtPassword.setText("");
						mdlAccHistory.setRowCount(0);
						mdlAccStat.setRowCount(0);
						btnOK.setEnabled(false);
					}
					else if(trString.equals("2222XX"))
					{
						System.out.println("2222XX");
						txtResult.setText("해당 계좌가 존재하지 않습니다");
						//setEmpty(allComponents);
						txtAccName.setText("");
						txtPassword.setText("");
						mdlAccHistory.setRowCount(0);
						mdlAccStat.setRowCount(0);
						btnOK.setEnabled(false);
					}
					else if(trString.equals("2222PX"))
					{
						System.out.println("2222PX");
						txtResult.setText("비밀번호가 일치하지 않습니다");
						txtPassword.setText("");
						btnOK.setEnabled(false);
						mdlAccHistory.setRowCount(0);
						mdlAccStat.setRowCount(0);
					}
					else if(trString.equals("2222OW"))
					{
						System.out.println("2222OW");
						if(cmbProcessType.getSelectedIndex()==0)
							txtResult.setText("등록할 사고 유형을 선택하여 주십시오");
						else
							txtResult.setText("해지할 사고 내역을 선택하여 주십시오");
						mdlAccHistory.setRowCount(0);
						mdlAccStat.setRowCount(0);
						requestSagoList();
						btnOK.setEnabled(true);
					}
					else if(trString.equals("20010A"))
					{
						txtResult.setText("이미 등록된 사고입니다");
					}
					else if(trString.equals("20011A"))
					{
						txtResult.setText("종합계좌에서 등록된 사고입니다. 종합계좌로 조회 후 해지 가능합니다");
					}
					else if(trString.equals("20011R") || trString.equals("20010R"))
					{
						if(trString.equals("20011R"))
							txtResult.setText("사고 해지가 완료되었습니다");
						else
							txtResult.setText("사고 등록이 완료되었습니다");
						mdlAccHistory.setRowCount(0);
						mdlAccStat.setRowCount(0);
						requestSagoList();
					}
					else if(trString.equals("20019T"))
					{
						byte[] readByte = new byte[4];
						rcvBuff.get(readByte, 0, 4);
						String sgTypeResult = new String(readByte, "UTF-8").trim();
						setLimitTable(-1);
						if(sgTypeResult.charAt(0)=='1')//출금고정지
							setLimitTable(0);
						if(sgTypeResult.charAt(1)=='1')//현물거래정지
							setLimitTable(1);
						if(sgTypeResult.charAt(2)=='1')//전거래정지
							setLimitTable(2);
						if(sgTypeResult.charAt(3)=='1')//불공정거래
							setLimitTable(3);
					}
					else if(trString.equals("200199"))
					{
						//사고 내역 조회 - 테이블에 채우기.
						//System.out.println("사고내역 조회");
						String[] historyRow = new String[4];
						String[] statRow = new String[5];
						
						//process_date
						byte[] readByte = new byte[20];
						rcvBuff.get(readByte, 0, 19);
						String enrollDate = new String(readByte, "UTF-8").trim(); 
						historyRow[2] = enrollDate;
						statRow[2] = enrollDate;
						
						//acc_num
						readByte = new byte[11];
						rcvBuff.get(readByte, 0, 11);
						historyRow[0] = new String(readByte, "UTF-8").trim();
						statRow[0] = historyRow[0];
						if(statRow[0].substring(3,5).equals("91"))
							statRow[1] = new String("종합계좌");
						else if(statRow[0].substring(3,5).equals("01")) 
							statRow[1] = new String("위탁계좌");
						else if(statRow[0].substring(3,5).equals("51"))
							statRow[1] = new String("선물계좌");
						
						//sg_id
						readByte = new byte[4];
						rcvBuff.get(readByte, 0, 4);
						statRow[4] = new String(readByte, "UTF-8").trim();
						
						//sg_check
						readByte = new byte[4];
						rcvBuff.get(readByte, 0, 4);
						String sg_check = new String(readByte, "UTF-8").trim();
						historyRow[1] = new String("등록");
												
						//sg_type
						readByte = new byte[4];
						rcvBuff.get(readByte, 0, 4);
						String sg_type = new String(readByte, "UTF-8").trim();
						if(sg_type.equals("0001"))
						{
							statRow[3] = "현물거래정지";
							historyRow[3] = "현물거래정지";
						}
						else if(sg_type.equals("0002"))
						{
							statRow[3] = "전거래정지";
							historyRow[3] = "전거래정지";
						}
						else if(sg_type.equals("0003"))
						{
							statRow[3] = "불공정거래";
							historyRow[3] = "불공정거래";
						}
						else if(sg_type.equals("0000"))
						{
							statRow[3] = "출금고정지";
							historyRow[3] = "출금고정지";
						}
						
						readByte = new byte[20];
						rcvBuff.get(readByte, 0, 19);
						String sg_cancel_date = new String(readByte, "UTF-8").trim();
						//"계좌번호","등록구분","사고등록일","사고유형"
						mdlAccHistory.addRow(historyRow);
						if(sg_cancel_date.length()>1)
						{
							String[] historyCancelRow = new String[4];
							historyCancelRow[0] = historyRow[0];
							historyCancelRow[3] = historyRow[3];
							historyCancelRow[2] = sg_cancel_date;
							historyCancelRow[1] = new String("해지");
							mdlAccHistory.addRow(historyCancelRow);
						}
						if(sg_check.equals("1111")) mdlAccStat.addRow(statRow);
						
					}
				}//try
				catch(Exception rcvex){}
			}
	    });
	    
		setTitle("CoreBASE [2001] 계좌사고등록/해지");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 800, 430);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		
		txtAccNum = new JFormattedTextField(mf1);
		txtAccNum.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if (e.getKeyCode() == KeyEvent.VK_ENTER || e.getKeyCode()==KeyEvent.VK_TAB) {
					findAccountName();
				}
			}
		});
		txtAccNum.setBounds(110, 35, 116, 21);
		txtAccNum.setDocument(new JTextFieldLimit(13));
		contentPane.add(txtAccNum);
		txtAccNum.setColumns(10);
		
		txtAccName = new JTextField();
		txtAccName.setFocusable(false);
		txtAccName.setEditable(false);
		txtAccName.setBounds(238, 35, 116, 21);
		contentPane.add(txtAccName);
		txtAccName.setColumns(10);
		
		JLabel lblNewLabel = new JLabel("비밀번호");
		lblNewLabel.setBounds(431, 38, 90, 15);
		contentPane.add(lblNewLabel);
		
		txtPassword = new JPasswordField();
		txtPassword.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if (e.getKeyCode() == KeyEvent.VK_ENTER) {
						getSagoListByPW();
				}
			}
		});
		txtPassword.setEchoChar('*');
		txtPassword.setDocument(new JTextFieldLimit(4));
		txtPassword.setBounds(533, 36, 60, 21);
		contentPane.add(txtPassword);
		
		/**
		 * 전송 버튼
		 */
		JButton btnSend = new JButton("전송");
		btnSend.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				getSagoListByPW();
			}
		});
		btnSend.setBounds(715, 65, 65, 23);
		contentPane.add(btnSend);
		String ta1 [] = {"","","",""};
		String ta3 [] = {"계좌번호","계좌유형","사고등록일","사고유형", "sg_id"};
		String ta5 [] = {"계좌번호","등록구분","사고처리일","사고유형"};
		
		txtResult = new JTextField();
		txtResult.setEditable(false);
		txtResult.setBounds(8, 365, 780, 21);
		contentPane.add(txtResult);
		txtResult.setColumns(10);
		
		scpAccLimit = new JScrollPane();
		scpAccLimit.setBounds(8, 252, 380, 98);
		contentPane.add(scpAccLimit);
		
		Object[][] data1 = new Object[][] {
				{"창구입금", null, "온라인입금", null},
				{"창구입고", null, "온라인입고", null},
				{"창구출금", null, "온라인출금", null},
				{"창구출고", null, "온라인출고", null},
				{"타점출금", null, "현물매수", null},
				{"타점출고", null, "현물매도", null},
		};
		
		mdlAccLimit = new DefaultTableModel(data1,ta1);
		tblAccLimit = new JTable(mdlAccLimit);
		tblAccLimit.setEnabled(false);
		tblAccLimit.setTableHeader(null);
		scpAccLimit.setColumnHeaderView(tblAccLimit);
		
		scpAccStat = new JScrollPane();
		scpAccStat.setEnabled(false);
		scpAccStat.setBounds(8, 136, 380, 88);
		contentPane.add(scpAccStat);
		
		
		mdlAccStat=new DefaultTableModel(null,ta3);
		tblAccStat = new JTable(mdlAccStat){
			@Override
			public boolean isCellEditable(int row, int column) {
				return false;
			}
		};
		tblAccStat.getTableHeader().setReorderingAllowed(false);
		tblAccStat.getTableHeader().setResizingAllowed(false);
		tblAccStat.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		//테이블 순서변경금지, 리사이징 금지, 한줄만 선택 가능, 편집금지.
		
		tblAccStat.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				JTable tbl = (JTable)e.getSource();
				int row = tbl.getSelectedRow();
				System.out.println(tbl.getValueAt(row, 4)); //sg_id
				tableSelectedRow = row;
			}
		});
		
		TableColumn tblClm = tblAccStat.getColumnModel().getColumn(4);
		tblClm.setMinWidth(0);
		tblClm.setMaxWidth(0);
		tblClm.setPreferredWidth(0);
		tblClm.setWidth(0);
		
		scpAccStat.setViewportView(tblAccStat);
		
		lblNewLabel_1 = new JLabel("계좌업무제한");
		lblNewLabel_1.setBounds(8, 234, 115, 15);
		contentPane.add(lblNewLabel_1);
		
		lblNewLabel_3 = new JLabel("계좌사고상태");
		lblNewLabel_3.setBounds(8, 114, 121, 15);
		contentPane.add(lblNewLabel_3);
		
		scpAccHistory = new JScrollPane();
		scpAccHistory.setEnabled(false);
		scpAccHistory.setBounds(400, 136, 388, 216);
		contentPane.add(scpAccHistory);
		
		mdlAccHistory = new DefaultTableModel(null,ta5);
		tblAccHistory = new JTable(mdlAccHistory);
		tblAccHistory.setEnabled(false);
		scpAccHistory.setViewportView(tblAccHistory);
		
		label = new JLabel("계좌사고이력");
		label.setBounds(400, 114, 121, 15);
		contentPane.add(label);
		
		lblNewLabel_2 = new JLabel("계좌번호");
		lblNewLabel_2.setBounds(8, 38, 90, 15);
		contentPane.add(lblNewLabel_2);
		
		lblNewLabel_4 = new JLabel("처리구분");
		lblNewLabel_4.setBounds(8, 10, 90, 15);
		contentPane.add(lblNewLabel_4);
		
		cmbProcessType = new JComboBox();
		cmbProcessType.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				btnOK.setEnabled(false);
			}
		});
		cmbProcessType.setFocusable(false);
		cmbProcessType.setModel(new DefaultComboBoxModel(new String[] {"등록", "해지"}));
		cmbProcessType.setBounds(110, 7, 116, 23);
		contentPane.add(cmbProcessType);
		
		lblNewLabel_6 = new JLabel("사고유형");
		lblNewLabel_6.setBounds(8, 69, 57, 15);
		contentPane.add(lblNewLabel_6);
		
		btnOK = new JButton("확인");
		btnOK.setEnabled(false);
		/**
		 * 확인 버튼
		 */
		btnOK.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				ByteBuffer sendBuffer = ByteBuffer.allocateDirect(1024);
				sendBuffer.clear();
				switch(cmbProcessType.getSelectedIndex())
				{
				case 0:
					System.out.println("등록하자");
					sendBuffer.position(0);
					sendBuffer.limit(6);
					sendBuffer.put("20010S".getBytes());
					
					sendBuffer.position(sendBuffer.limit());
					sendBuffer.limit(sendBuffer.limit()+11);
					sendBuffer.put(txtAccNum.getText().replaceAll("-", "").getBytes());
					
					sendBuffer.position(sendBuffer.limit());
					sendBuffer.limit(sendBuffer.limit()+4);
					sendBuffer.put("1111".getBytes());
					
					sendBuffer.position(sendBuffer.limit());
					sendBuffer.limit(sendBuffer.limit()+4);
					sendBuffer.put(String.format("%04d", cmbAccidentType.getSelectedIndex()).getBytes());
					
					sendBuffer.limit(1024);
					sendBuffer.rewind();
					client.writeBuffer(sendBuffer);
					sendBuffer.clear();
					
					break;
				case 1:
					System.out.println("해지한다");
					if(tableSelectedRow == -1)
					{
						txtResult.setText("해지할 내역을 선택하십시오.");
						break;
					}
					sendBuffer.position(0);
					sendBuffer.limit(6);
					sendBuffer.put("20011S".getBytes());
					
					sendBuffer.position(sendBuffer.limit());
					sendBuffer.limit(sendBuffer.limit()+11);
					sendBuffer.put(tblAccStat.getValueAt(tableSelectedRow, 0).toString().getBytes());
					
					sendBuffer.position(sendBuffer.limit());
					sendBuffer.limit(sendBuffer.limit()+4);
					sendBuffer.put("1122".getBytes());
					
					sendBuffer.position(sendBuffer.limit());
					sendBuffer.limit(sendBuffer.limit()+4);
					String sagoType = tblAccStat.getValueAt(tableSelectedRow, 3).toString();
					if(sagoType.equals("현물거래정지"))
					{
						sendBuffer.put("0001".getBytes());
					}
					else if(sagoType.equals("전거래정지"))
					{
						sendBuffer.put("0002".getBytes());
					}
					else if(sagoType.equals("불공정거래"))
					{
						sendBuffer.put("0003".getBytes());
					}
					else if(sagoType.equals("출금고정지"))
					{
						sendBuffer.put("0000".getBytes());
					}
										
					// 해지할 사고가 등록된 sg_id
					sendBuffer.position(sendBuffer.limit());
					sendBuffer.limit(sendBuffer.limit()+4);
					sendBuffer.put(tblAccStat.getValueAt(tableSelectedRow, 4).toString().getBytes());
					
					sendBuffer.limit(1024);
					sendBuffer.rewind();
					client.writeBuffer(sendBuffer);
					sendBuffer.clear();
					tableSelectedRow = -1;
					
					break;
				}
			}
		});
		btnOK.setBounds(638, 65, 65, 23);
		contentPane.add(btnOK);
		
		cmbAccidentType = new JComboBox();
		cmbAccidentType.setModel(new DefaultComboBoxModel(new String[] {"출금고정지", "현물거래정지", "전거래정지", "불공정거래"}));
		cmbAccidentType.setBounds(110, 66, 244, 23);
		contentPane.add(cmbAccidentType);
		
		separator = new JSeparator();
		separator.setBounds(8, 102, 780, 2);
		contentPane.add(separator);
		
		
		TableCellRenderer ren = new TableColor();
		TableCellRenderer ren2 = new TableColor2();

		tblAccStat.setColumnSelectionAllowed(false);
		tblAccStat.setRowSelectionAllowed(true);
		
		try {
			tblAccLimit.setDefaultRenderer(Class.forName("java.lang.Object"), ren2);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
		try {
			tblAccHistory.setDefaultRenderer(Class.forName("java.lang.Object"), ren);
			tblAccStat.setDefaultRenderer(Class.forName("java.lang.Object"), ren);
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
		
	}
	public void setLimitTable(int a)
	{
		if(a==-1)
		{
			for(int i=0; i<6; i++)
				for(int j=1; j<4; j=j+2)
					tblAccLimit.setValueAt("가능", i, j);
		}
		else if(a==0)//출금고정지
		{
			for(int i=2; i<6; i++)
				tblAccLimit.setValueAt("불가능", i, 1);
			tblAccLimit.setValueAt("불가능", 2, 3);
			tblAccLimit.setValueAt("불가능", 3, 3);
		}
		else if(a==1)//현물거래정지
		{
			tblAccLimit.setValueAt("불가능", 4, 3);
			tblAccLimit.setValueAt("불가능", 5, 3);
		}
		else if(a==2)//전거래정지
		{
			setLimitTable(0);
			setLimitTable(1);
		}
		else if(a==3)//불공정거래
		{
			tblAccLimit.setValueAt("불가능", 4, 3);
		}
	}
	public void requestSagoList()
	{
		String sendString = "200199"+String.format("%11s", txtAccNum.getText().replaceAll("-", ""));
		client.writeString(sendString);
	}
	
	public void findAccountName()
	{
		if(txtAccNum.getText().length()==13)
		{
			String accountFindString = "2222ID";
			accountFindString+=String.format("%11s", txtAccNum.getText().replaceAll("-", ""));
			client.writeString(accountFindString);//+"$");
			System.out.println("계좌조회"+accountFindString);
			txtResult.setText("계좌조회");
		}
		else
		{
			txtResult.setText("계좌번호 11자리를 입력해 주세요.");	
		}
	}
	
	public void getApryuListByAccPW()
	{
		if(txtPassword.getPassword().length!=4)
		{
			if(txtAccNum.getText().length()!=11)
			{
				txtResult.setText("계좌번호11자리, 비밀번호4자리를 입력하여 주십시오.");
			}
			else
			{
				txtResult.setText("비밀번호 4자리를 바르게 입력하여 주십시오.");
			}
		}
		else
		{
			if(txtAccName.getText().isEmpty()) findAccountName();
			// 사고 내역 조회
			String accountFindString = "2222IW";
			accountFindString+=String.format("%11s%4s", txtAccNum.getText().replaceAll("-", ""), new String(txtPassword.getPassword()));
			client.writeString(accountFindString);//+"$");
			//System.out.println(accountFindString);
			txtResult.setText("");
		}
	}
	
	public void getSagoListByPW()
	{
		if(txtPassword.getPassword().length!=4)
		{
			if(txtAccNum.getText().length()!=11)
			{
				txtResult.setText("계좌번호11자리, 비밀번호4자리를 입력하여 주십시오.");
			}
			else
			{
				txtResult.setText("비밀번호 4자리를 바르게 입력하여 주십시오.");
			}
		}
		else
		{
			if(txtAccName.getText().isEmpty()) findAccountName();
			//System.out.println("질권 설정 내역 조회");
			// 압류 내역 조회.
			String accountFindString = "2222IW";
			accountFindString+=String.format("%11s%4s", txtAccNum.getText().replaceAll("-", ""), new String(txtPassword.getPassword()));
			client.writeString(accountFindString);//+"$");
			//System.out.println(accountFindString);
			txtResult.setText("");
		}
	}
	
	public class TableColor extends DefaultTableCellRenderer {

		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

			Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

			// 가운데 정렬
			this.setHorizontalAlignment(JLabel.CENTER);

			// 색 삽입
			if (row%2==1) {
				cell.setBackground(new Color(195, 217, 235));
			} else {
				cell.setBackground(Color.WHITE);
			}

			return cell;

		}

	}
	
	public class TableColor2 extends DefaultTableCellRenderer {

		public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {

			Component cell = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);

			// 가운데 정렬
			this.setHorizontalAlignment(JLabel.CENTER);

			// 색 삽입
			if (column == 0 || column == 2) {
				cell.setBackground(new Color(195, 217, 235));
			}  else {
				cell.setBackground(Color.WHITE);
			}

			return cell;

		}

	}
}
